﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using HtmlAgilityPack;
using System.Configuration;
using DWH.Configuration;
using System.Xml;
using System.IO;

namespace RDTest
{
    [TestClass]
    public class SimpleTest
    {
        [TestMethod]
        public void TestMethod1()
        {
            HtmlWeb web = new HtmlWeb();

            HtmlDocument doc = web.Load("http://docs.nuget.org/docs/start-here/installing-nuget");

            //foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
            //{
            //    HtmlAttribute att = link.Attributes["href"];

            //    Console.WriteLine(att.Value);
            //}


            foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//img[@src]"))
            {
                HtmlAttribute att = link.Attributes["src"];

                Console.WriteLine(att.Value);
            }

            Console.ReadKey();
        }

        [TestMethod]
        public void SimpleTTest()
        {
            //string a = "http://docs.nuget.org/docs/start-here/installing-nuget";

            HtmlWeb web = new HtmlWeb();
            web.OverrideEncoding = Encoding.GetEncoding("gb2312");

            HtmlDocument doc = web.Load("http://70.85.48.252/bt/thread.php?fid=14");
        }

        [TestMethod]
        public void SortTest()
        {
            List<string> tempPageContentUrls = new List<string>();
            
            tempPageContentUrls.Add("http://istorrs.com/download/?paged=40");
            tempPageContentUrls.Add("http://istorrs.com/download/?paged=32");
            tempPageContentUrls.Add("http://istorrs.com/download/?paged=23");
            tempPageContentUrls.Add("http://istorrs.com/download/?paged=45");
            tempPageContentUrls.Add("http://istorrs.com/download/?paged=54");
            tempPageContentUrls.Add("http://istorrs.com/download/?paged=63");
            tempPageContentUrls.Add("http://istorrs.com/download/?paged=163");

            tempPageContentUrls.Sort((x, y) => (-1) * String.Compare(x, y, true));

            var filtered = tempPageContentUrls.FindAll(x => String.Compare(x,"http://istorrs.com/download/?paged=45") > 0);           
        }

        [TestMethod]
        [DeploymentItem("RDConfiguration_PushTasks.config")]
        public void ConfigurationTest()
        {
            XmlDocument doc = new XmlDocument();
            doc.Load("RDConfiguration_PushTasks.config");
            List<RDTaskConfiguration> rds = RDConfigurationHandler.LoadFromXmlNode(doc.DocumentElement);
        }

        [TestMethod]
        public void PathTest()
        {
            string ext = Path.GetExtension("E:/640/11091839");
        }


        [TestMethod]
        public void EnumTest()
        {
            List<string> a = new List<string> { "A", "b", "c" };

            List<string> b = a.Where(x => x == "A").ToList<string>();

            Func<int,int, int> add = (int x, int y) => x + y;           

        }       

    }

   
}
